<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 手写函数柯里化
        const curring = function (fn) {
            const args = [];
            return function result(...rest) {
                if (rest.length === 0) {
                    return fn(...args)
                } else {
                    args.push(...rest);
                    return result;
                }
            }
        }
        const sum = (...arg) => {
            return arg.reduce((pre, cur) => {
                return pre + cur
            }, 0)
        }

        curring(sum)(1)(2, 5)(3)()

    </script>
</body>

</html>